<template>
    <div class='resentConte'>
        <div class="list">
            <div class="mod" v-for="v in secentList" :key="v.data.id" @click="addListToPlay(v.data.id, v.data)">
                <div>
                    <h3>{{ v.data.name }}</h3>
                    <p class="mod-p"><van-tag type="primary">{{ v.data.ar[0].name }}</van-tag>
                    </p>
                </div>
                <div class="mod-r">
                    <div v-if="v.data.mv">
                        <van-icon color="#aaa" name="play-circle-o" />
                    </div>
                    <van-icon color="#aaa" name="ellipsis" />
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'resentConte',
    data() {
        return {}
    },
    computed: {},
    components: {},
    created() { },
    mounted() { },
    methods: {
        addListToPlay(id, song) {
            this.$router.push({ name: 'play' });
            // song.id 通过vuex来更改对应的id以及存入对应的song
            this.$store.dispatch('toggleSong', id);
            // 存储对应的歌曲
            this.$store.dispatch('addPlayList', song);
        },
        playAll() {
            // 添加到播放列表
            this.$store.dispatch('addPlayList', this.searchList);
            // 切换歌曲
            this.$store.dispatch('toggleSong', this.searchList[0].id);
        }
    },
    props: {
        secentList: {
            default: [],
            type: Array
        }
    }
}
</script>
<style scoped>
hr {
    width: 98%;
    background: #eee;
    margin: 0 auto;
}

p {
    margin: 5px;
}

h3 {
    font-weight: normal;
    color: #1989fa;
    margin: 5px;
    font-size: 16px;
}

.tit {
    padding: 50px 20px 0;

}

.list {
    padding: 0 20px;
}

.mod-p {
    font-size: 12px;
}

.mod-r {
    display: flex;
    align-self: center;
}

.box>.title {
    display: flex;
    justify-content: space-between;
}

.box {
    width: 80%;
    margin: 10px auto;
    background-color: #fff;
    border-radius: 15px;
    padding: 10px 20px;
}

.title>button {
    border: 1px solid red;
    border-radius: 20px;
    color: red;
    background-color: #fff;
    font-size: 12px;
}

.mod {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.mod .van-icon {
    margin-left: 30px;
    font-size: 22px;
}
</style>
